<div class="w-72 hidden flex flex-col bg-dark-800/70 backdrop-blur rounded-xl border-2 border-dark-700" id="node_select_popup">
    {% for node_alias in specter.node_manager.nodes %}
        {% set node = specter.node_manager.get_by_alias(node_alias) %}
        {% set selected_node = node_alias == specter.node.alias %}
        {% set running = node.is_running %}
        <form class="py-2 pl-2 pr-3 group hover:bg-dark-700 {% if selected_node %} bg-dark-700 {% endif %}" action="{{url_for('nodes_endpoint.switch_node')}}" id="{{node.alias}}-select-node-form" method="POST">
            <input type="hidden" class="csrf-token" name="csrf_token" value="{{ csrf_token() }}"/>
            <input type="hidden" name="node_alias" value="{{ node.alias }}"/>

            <div class="cursor-pointer flex text-white items-center space-x-2 {% if node.alias == specter.node.alias %}active{% endif %}" onclick="document.getElementById('{{node.alias}}-select-node-form').submit();">
                <div class="w-10 flex justify-center {% if running %} opacity-100 {% else %} opacity-20 {% endif %}">
                    {% include node.node_logo_template() %}
                </div>

                <div class="min-w-0" id="node_item" {% if selected_node %} title="Selected node" {% else %} title="Select node" {% endif%}>
                    <div class="min-w-0 flex items-center space-x-2 mr-2">
                        <div id="overlay-connection-name" class="truncate leading-1 text-base">
                            {% if node.alias == "spectrum_node" %}
                                {{ _("Bitcoin Network") }}
                            {% else %} 
                                {{ node.name }} 
                            {% endif %}
                        </div>
                        <svg class="w-5 h-5 {% if not running %} opacity-20 {% endif %}"version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><!--Generated by IJSVG (https://github.com/iconjar/IJSVG)--><path d="M54.5946,27.4366l5.66603e-08,-5.66066e-08c-0.745305,0.744598 -1.9414,0.780481 -2.73,0.0819001l1.11948e-07,9.86842e-08c-11.3381,-9.99478 -28.3408,-9.99478 -39.6789,-1.97368e-07l4.1375e-08,-3.6659e-08c-0.788564,0.698682 -1.98474,0.662797 -2.73,-0.0818999l-2.831,-2.8295l4.78383e-08,4.78239e-08c-0.782846,-0.782609 -0.783038,-2.05166 -0.000429116,-2.83451c0.0255969,-0.0256047 0.0518829,-0.0505111 0.078829,-0.0746918l-1.08875e-06,9.72979e-07c14.4215,-12.888 36.2226,-12.888 50.6441,-1.94596e-06l-4.18137e-09,-3.75185e-09c0.823858,0.73923 0.892463,2.00636 0.153233,2.83022c-0.0242251,0.0269984 -0.0491787,0.0533343 -0.0748332,0.0789783Zm-17.6311,13.896l1.74829e-07,9.87123e-08c1.00267,0.56613 1.35656,1.8379 0.79043,2.84057c-0.0942659,0.166954 -0.21111,0.320108 -0.34723,0.45513l-3.6928,3.6684l2.2751e-08,-2.25368e-08c-0.943884,0.934995 -2.46482,0.934995 -3.4087,4.50735e-08l-3.6928,-3.6684l-6.02819e-08,-5.98007e-08c-0.8175,-0.810974 -0.82279,-2.13111 -0.0118161,-2.94861c0.134967,-0.136053 0.288047,-0.252849 0.454916,-0.347088l2.96297e-07,-1.66902e-07c3.07549,-1.7324 6.83251,-1.7324 9.908,3.33805e-07Zm-14.8508,-3.792l3.86385e-08,-3.1954e-08c-0.835403,0.690877 -2.05882,0.634623 -2.8273,-0.13l-2.3847,-2.4084c-1.1739,-1.1855 -1.14,-2.6381 -0.1975,-3.4266l9.62086e-07,-8.05987e-07c8.84671,-7.41133 21.7347,-7.41133 30.5814,1.61198e-06l-5.08261e-08,-4.40698e-08c0.88879,0.770643 0.984568,2.11588 0.213926,3.00467c-0.0332999,0.0384052 -0.0679639,0.075606 -0.103925,0.111531l-2.6883,2.7151l2.63897e-08,-2.62774e-08c-0.768944,0.765671 -1.99317,0.823532 -2.8309,0.1338l-1.43462e-07,-1.17058e-07c-5.75168,-4.69307 -14.0109,-4.69307 -19.7626,2.34116e-07Z" fill="currentColor" fill-rule="evenodd"></path></svg>
                    </div>
                    <div class="leading-0 text-dark-200 text-sm">
                        {% if running %}
                            {% if node.alias == "spectrum_node" %}
                                {% if node.chain == "main" %}
                                    {{ node.name }}
                                {% else %}
                                    {{ node.name }} ({{node.chain | title }})
                                {% endif %}
                            {% else %}
                                {% if node.node_type == "BTC" %}
                                    {% if node.chain == "main" %}
                                        Bitcoin Network
                                    {% else %}
                                        Bitcoin Network ({{node.chain | title }})
                                    {% endif %}
                                {% else %}
                                    {% if node.chain == "main" %}
                                        Liquid Network
                                    {% else %}
                                        Liquid Network ({{node.chain | title }})
                                    {% endif %}
                                {% endif %}
                            {% endif %}
                        {% else %}
                            {{ _("Unreachable...") }}
                        {% endif %}
                    </div>
                </div>

                <a class="hidden group-hover:flex text-white border-t-1 border-dark-700 self-center justify-end grow" title="Configure node" href="{{ url_for('nodes_endpoint.node_settings', node_alias=node.alias) }}" onclick='event.stopPropagation();'>
                    <svg class="w-6 h-6" version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><!--Generated by IJSVG (https://github.com/iconjar/IJSVG)--><path d="M57.2844,34.2283l-3.9883,1.1395l3.17612e-08,-9.30007e-09c-0.360653,0.105603 -0.63181,0.404255 -0.7022,0.7734l2.47041e-07,-1.2278e-06c-0.177144,0.880411 -0.411338,1.74838 -0.7011,2.5984l-3.83885e-08,1.09619e-07c-0.124404,0.355235 -0.0388029,0.750235 0.2215,1.0221l2.8877,2.9844l-2.38852e-08,-2.46905e-08c0.310719,0.321195 0.370947,0.809422 0.1476,1.1965l-1.245,2.1564l1.45129e-08,-2.51485e-08c-0.223405,0.387125 -0.676446,0.579157 -1.11,0.4705l-4.05,-1.014l9.02177e-08,2.20782e-08c-0.364739,-0.0892593 -0.74875,0.0331841 -0.9945,0.3171l1.13486e-07,-1.29147e-07c-0.588383,0.669581 -1.2184,1.3014 -1.88629,1.89169l-5.24411e-08,4.53795e-08c-0.283821,0.245602 -0.406362,0.629363 -0.3174,0.994l1.01259,4.04671l3.48472e-08,1.38981e-07c0.108676,0.433433 -0.0831197,0.886398 -0.47,1.11l-2.1569,1.245l5.55443e-08,-3.20886e-08c-0.387013,0.223582 -0.875373,0.163379 -1.1965,-0.1475l-2.9992,-2.9018l2.9806e-09,2.85976e-09c-0.271609,-0.260598 -0.666603,-0.346484 -1.0219,-0.2222l-8.55655e-07,2.93141e-07c-0.844355,0.28927 -1.70648,0.523822 -2.581,0.7022l-1.77682e-08,3.4177e-09c-0.368526,0.0708855 -0.666568,0.341721 -0.7723,0.7018l-1.1433,4.0023l-9.60767e-10,3.35976e-09c-0.122881,0.42971 -0.515666,0.725951 -0.9626,0.726h-2.49l1.95129e-10,1.42109e-14c-0.446946,-1.56839e-05 -0.839748,-0.29627 -0.9626,-0.726l-1.1427,-4.0013l2.85457e-08,9.75162e-08c-0.105597,-0.360733 -0.404287,-0.631968 -0.7735,-0.7024l-2.04429e-06,-4.10898e-07c-0.876453,-0.176166 -1.74062,-0.408749 -2.58709,-0.696297l-6.37117e-08,-2.22625e-08c-0.355023,-0.124054 -0.749632,-0.0382612 -1.0211,0.222l-2.9929,2.8957l2.97278e-08,-2.87776e-08c-0.321159,0.310895 -0.809556,0.371098 -1.1966,0.1475l-2.1564,-1.2449l1.7065e-08,9.86637e-09c-0.386827,-0.223649 -0.578606,-0.676573 -0.47,-1.11l1.0147,-4.0524l1.33503e-08,-5.46011e-08c0.089308,-0.365259 -0.033593,-0.749759 -0.3182,-0.9955l4.36958e-07,3.82755e-07c-0.670548,-0.587369 -1.30328,-1.21656 -1.8944,-1.8838l9.23384e-09,1.06423e-08c-0.245655,-0.283127 -0.628953,-0.405207 -0.9931,-0.3163l-4.0444,1.0125l8.775e-08,-2.19707e-08c-0.433546,0.10855 -0.886524,-0.083455 -1.11,-0.4705l-1.24581,-2.1565l-1.00625e-08,-1.74301e-08c-0.223442,-0.387042 -0.16325,-0.875311 0.1475,-1.1965l2.8936,-2.99l3.5126e-08,-3.66489e-08c0.260682,-0.271984 0.346382,-0.667393 0.2217,-1.0229l-3.91852e-07,-1.14069e-06c-0.291297,-0.847972 -0.52739,-1.71391 -0.706798,-2.59239l1.30901e-09,6.829e-09c-0.0706561,-0.368607 -0.341534,-0.666738 -0.7017,-0.7723l-3.9891,-1.14l-1.47934e-08,-4.22479e-09c-0.429791,-0.122743 -0.726066,-0.515626 -0.7259,-0.9626v-2.49l-8.92497e-09,-2.4941e-05c-0.000154376,-0.446974 0.29613,-0.83985 0.725924,-0.962582l3.9883,-1.14l-2.31839e-08,6.79308e-09c0.360615,-0.105663 0.6317,-0.404358 0.702,-0.7735l-5.95606e-08,2.95638e-07c0.177365,-0.880379 0.411623,-1.74833 0.7013,-2.5984l5.45882e-09,-1.55782e-08c0.124479,-0.355233 0.0387827,-0.750276 -0.2217,-1.022l-2.88763,-2.9838l4.2055e-08,4.34676e-08c-0.31075,-0.321188 -0.370942,-0.809458 -0.1475,-1.1965l1.2449,-2.1565l-2.27863e-08,3.94183e-08c0.223626,-0.386854 0.67657,-0.578641 1.11,-0.47l4.0507,1.0141l1.71017e-08,4.18028e-09c0.364775,0.0891641 0.748769,-0.033351 0.9945,-0.3173l1.10855e-06,-1.26178e-06c0.58829,-0.669605 1.21824,-1.30143 1.8861,-1.8917l2.41601e-08,-2.08918e-08c0.283906,-0.245501 0.406435,-0.629306 0.3173,-0.9939l-1.0132,-4.0467l3.12657e-09,1.24656e-08c-0.108712,-0.433435 0.0830929,-0.886421 0.47,-1.11l2.1564,-1.245l-1.66979e-07,9.64141e-08c0.387051,-0.223485 0.875355,-0.163334 1.1966,0.1474l2.9993,2.902l-8.6721e-08,-8.31209e-08c0.27176,0.260478 0.666772,0.346275 1.0221,0.222l1.63393e-06,-5.59558e-07c0.844263,-0.289127 1.70624,-0.523677 2.5806,-0.7022l1.06423e-07,-2.04098e-08c0.368622,-0.0706944 0.666749,-0.341608 0.7723,-0.7018l1.1435,-4.0023l1.79162e-08,-6.2652e-08c0.122881,-0.42971 0.515666,-0.725951 0.9626,-0.726h2.49l-1.81415e-08,-3.36797e-12c0.446923,8.29866e-05 0.839689,0.29631 0.9626,0.726l1.1432,4.0014l3.05866e-09,1.04512e-08c0.105576,0.360746 0.404276,0.631989 0.7735,0.7024l9.2933e-07,1.86777e-07c0.876467,0.176152 1.74063,0.408769 2.58709,0.696397l9.1859e-08,3.2039e-08c0.355053,0.123837 0.749563,0.0380269 1.0211,-0.2221l2.9928,-2.8956l-6.39387e-08,6.18999e-08c0.321119,-0.310879 0.809458,-0.371121 1.1965,-0.1476l2.1564,1.245l6.29435e-08,3.63663e-08c0.386934,0.223555 0.578747,0.676562 0.47,1.11l-1.0145,4.0524l3.03479e-08,-1.24066e-07c-0.0893391,0.36523 0.03357,0.749717 0.3182,0.9954l-4.44877e-07,-3.89742e-07c0.670492,0.587396 1.30319,1.21658 1.8943,1.8838l5.44063e-08,6.27484e-08c0.245558,0.283209 0.628879,0.405308 0.993,0.3163l4.0446,-1.0124l1.88154e-08,-4.7207e-09c0.433438,-0.108747 0.886445,0.0830663 1.11,0.47l1.2448,2.1565l2.00317e-08,3.46804e-08c0.223538,0.387006 0.163382,0.875318 -0.1474,1.1965l-2.8935,2.9905l7.58168e-09,-7.91098e-09c-0.260643,0.271964 -0.346341,0.667323 -0.2217,1.0228l3.97908e-07,1.1585e-06c0.291265,0.848011 0.527325,1.71399 0.7067,2.5925l-4.45918e-08,-2.32536e-07c0.0706729,0.368543 0.3415,0.666623 0.7016,0.7722l3.9893,1.14l5.00553e-09,1.42976e-09c0.42979,0.122764 0.726085,0.515621 0.726,0.9626v2.49l1.04571e-09,-4.57524e-05c0,0.446542 -0.295802,0.839069 -0.72505,0.962137Zm-34.642,-14.4332l1.20408e-08,2.09575e-08c-0.139243,-0.242359 -0.448593,-0.325951 -0.690952,-0.186708c-0.0217675,0.0125061 -0.0425744,0.0266145 -0.0622482,0.0422084l-7.06444e-07,5.75336e-07c-6.83176,5.56387 -7.8596,15.6125 -2.29573,22.4443c0.685183,0.841323 1.45441,1.61055 2.29573,2.29573l-3.24386e-08,-2.57046e-08c0.219114,0.173628 0.537494,0.136754 0.711121,-0.0823603c0.0155403,-0.0196115 0.029605,-0.0403482 0.0420786,-0.0620397l5.76,-9.9758l-3.27835e-08,5.67828e-08c0.803848,-1.3923 0.803848,-3.1077 6.55671e-08,-4.5Zm9.3676,-3.7751l-3.97185e-08,-4.28564e-11c-1.93584,-0.00208884 -3.8559,0.348046 -5.6664,1.0333l1.59642e-08,-6.32588e-09c-0.258314,0.102358 -0.384741,0.39474 -0.282384,0.653053c0.00930422,0.0234805 0.0203634,0.046227 0.0330837,0.0680467l5.7712,9.9961l1.04316e-07,1.80681e-07c0.803845,1.3923 2.28941,2.24999 3.8971,2.25h11.5258l2.01323e-08,1.22746e-11c0.279566,0.000170446 0.506338,-0.226325 0.506509,-0.505891c1.51213e-05,-0.0248021 -0.0017926,-0.0495717 -0.00540855,-0.0741087l5.76739e-08,3.53837e-07c-1.26087,-7.73562 -7.94179,-13.4178 -15.7795,-13.4205Zm15.2779,18h-11.5248l1.72855e-07,-5.47118e-13c-1.60769,5.05322e-06 -3.09326,0.857699 -3.8971,2.25l-5.7712,9.996l-2.04905e-08,3.51481e-08c-0.139939,0.240042 -0.0587888,0.548078 0.181253,0.688016c0.0218196,0.0127203 0.0445662,0.0237795 0.0680467,0.0330837l9.02978e-07,3.41327e-07c8.2646,3.12404 17.4969,-1.04322 20.621,-9.30782c0.376648,-0.996419 0.652834,-2.02797 0.824446,-3.07928l2.5842e-09,-1.77608e-08c0.040261,-0.276708 -0.151417,-0.533662 -0.428125,-0.573923c-0.0241659,-0.00351614 -0.0485545,-0.00527928 -0.0729748,-0.00527562Z" fill="currentColor" fill-rule="evenodd"></path></svg>
                </a>

                <a class="flex {% if not selected_node %}hidden{% endif %} group-hover:hidden text-accent border-t-1 border-dark-700 self-center justify-end grow" title="Selected Node">
                    <svg class="w-6 h-6" version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><!--Generated by IJSVG (https://github.com/iconjar/IJSVG)--><path d="M32.01,56.0208l-1.04907e-06,-2.13163e-14c-13.2548,-5.79387e-07 -24,-10.7452 -24,-24c5.79387e-07,-13.2548 10.7452,-24 24,-24c13.2548,5.79387e-07 24,10.7452 24,24l2.84217e-14,-1.04907e-06c0,13.2548 -10.7452,24 -24,24Zm13.4,-35.4186l-3.49088e-08,-3.45428e-08c-0.785624,-0.777389 -2.0527,-0.770712 -2.83008,0.0149119c-0.0803372,0.0811883 -0.153576,0.169105 -0.218915,0.262788l-12.8438,18.3901l-5.8744,-8.4112l5.28764e-08,7.58143e-08c-0.632255,-0.906528 -1.87968,-1.12887 -2.78621,-0.496615c-0.0936828,0.0653387 -0.1816,0.138578 -0.262788,0.218915l2.67369e-08,-2.81027e-08c-0.695734,0.731275 -0.767842,1.85586 -0.1712,2.67l6.6244,9.485l8.22893e-08,1.17716e-07c0.953738,1.36434 2.83291,1.69719 4.19725,0.743454c0.289461,-0.202347 0.541107,-0.453993 0.743454,-0.743454l13.5937,-19.4644l2.1684e-09,-2.9606e-09c0.596265,-0.814103 0.524082,-1.93834 -0.1714,-2.6695Z" fill="currentColor" fill-rule="evenodd"></path></svg>
                </a>

            </div>

        </form>
    {% endfor %}

    <a class="pl-4 py-3 text-base text-dark-200 font-medium hover:bg-dark-700 border-t-[1px] border-dark-700" href="{{ url_for('nodes_endpoint.node_settings_new_node_get')}}" id="btn_new_node_get" data-cy="new-connection-btn">+ Add Connection</a>
</div>

<script type="text/javascript">
    function showNodeSelectPopup(e) {
        // Show node selection popup when clicking on the arrows on the sidebar 
        // hidePageOverlay();

        if (!e) var e = window.event;
        e.cancelBubble = true;
        if (e.stopPropagation) { 
            e.stopPropagation(); 
            e.preventDefault();
        }

        document.getElementById('side-content').classList.remove('active');
        showPageOverlay('node_select_popup', { left: "16px", top: "64px" });

        // Change the default styling of the node selection popup 
        let pageOverlayPopup = document.getElementById('page_overlay_popup')
        pageOverlayPopup.classList.add('page_overlay_popup')
        let nodeSelectPopupContainer = document.getElementById('node_select_popup');
        nodeSelectPopupContainer.style.display = 'flex'
        nodeSelectPopupContainer.classList.add('node-select-popup-container')
    }

    function onCancelOverlay() {
        document.getElementById('page_overlay_popup').style.padding = '1.5em';
    }

    const overlayConnectionNameElement = document.getElementById("overlay-connection-name")
    document.addEventListener('connectionRenamed', (e) => {
        overlayConnectionNameElement.innerText = e.detail.newName
    })
</script>
